{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fictional Army - Filtering and Sorting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Introduction:\n",
    "\n",
    "This exercise was inspired by this [page](http://chrisalbon.com/python/)\n",
    "\n",
    "Special thanks to: https://github.com/chrisalbon for sharing the dataset and materials.\n",
    "\n",
    "### Step 1. Import the necessary libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:38:12.678235Z",
     "start_time": "2024-01-11T12:38:11.914523Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 2. This is the data given as a dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-01-11T12:40:28.183745Z",
     "start_time": "2024-01-11T12:40:28.171996Z"
    }
   },
   "outputs": [],
   "source": [
    "# Create an example dataframe about a fictional army\n",
    "raw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks', 'Dragoons', 'Dragoons', 'Dragoons', 'Dragoons', 'Scouts', 'Scouts', 'Scouts', 'Scouts'],\n",
    "            'company': ['1st', '1st', '2nd', '2nd', '1st', '1st', '2nd', '2nd','1st', '1st', '2nd', '2nd'],\n",
    "            'deaths': [523, 52, 25, 616, 43, 234, 523, 62, 62, 73, 37, 35],\n",
    "            'battles': [5, 42, 2, 2, 4, 7, 8, 3, 4, 7, 8, 9],\n",
    "            'size': [1045, 957, 1099, 1400, 1592, 1006, 987, 849, 973, 1005, 1099, 1523],\n",
    "            'veterans': [1, 5, 62, 26, 73, 37, 949, 48, 48, 435, 63, 345],\n",
    "            'readiness': [1, 2, 3, 3, 2, 1, 2, 3, 2, 1, 2, 3],\n",
    "            'armored': [1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1],\n",
    "            'deserters': [4, 24, 31, 2, 3, 4, 24, 31, 2, 3, 2, 3],\n",
    "            'origin': ['Arizona', 'California', 'Texas', 'Florida', 'Maine', 'Iowa', 'Alaska', 'Washington', 'Oregon', 'Wyoming', 'Louisana', 'Georgia']}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 3. Create a dataframe and assign it to a variable called army. \n",
    "\n",
    "#### Don't forget to include the columns names in the order presented in the dictionary ('regiment', 'company', 'deaths'...) so that the column index order is consistent with the solutions. If omitted, pandas will order the columns alphabetically."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:47:21.924193Z",
     "start_time": "2024-01-11T12:47:21.898531Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "      regiment company  deaths  battles  size  veterans  readiness  armored  \\\n0   Nighthawks     1st     523        5  1045         1          1        1   \n1   Nighthawks     1st      52       42   957         5          2        0   \n2   Nighthawks     2nd      25        2  1099        62          3        1   \n3   Nighthawks     2nd     616        2  1400        26          3        1   \n4     Dragoons     1st      43        4  1592        73          2        0   \n5     Dragoons     1st     234        7  1006        37          1        1   \n6     Dragoons     2nd     523        8   987       949          2        0   \n7     Dragoons     2nd      62        3   849        48          3        1   \n8       Scouts     1st      62        4   973        48          2        0   \n9       Scouts     1st      73        7  1005       435          1        0   \n10      Scouts     2nd      37        8  1099        63          2        1   \n11      Scouts     2nd      35        9  1523       345          3        1   \n\n    deserters      origin  \n0           4     Arizona  \n1          24  California  \n2          31       Texas  \n3           2     Florida  \n4           3       Maine  \n5           4        Iowa  \n6          24      Alaska  \n7          31  Washington  \n8           2      Oregon  \n9           3     Wyoming  \n10          2    Louisana  \n11          3     Georgia  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>California</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Texas</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Florida</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>43</td>\n      <td>4</td>\n      <td>1592</td>\n      <td>73</td>\n      <td>2</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Maine</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Iowa</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>Alaska</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>62</td>\n      <td>3</td>\n      <td>849</td>\n      <td>48</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Washington</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>Oregon</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Wyoming</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>37</td>\n      <td>8</td>\n      <td>1099</td>\n      <td>63</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Louisana</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>35</td>\n      <td>9</td>\n      <td>1523</td>\n      <td>345</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>Georgia</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army = pd.DataFrame(raw_data)\n",
    "army"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 4. Set the 'origin' colum as the index of the dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:49:29.091946Z",
     "start_time": "2024-01-11T12:49:29.042226Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "              regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                       \nArizona     Nighthawks     1st     523        5  1045         1          1   \nCalifornia  Nighthawks     1st      52       42   957         5          2   \nTexas       Nighthawks     2nd      25        2  1099        62          3   \nFlorida     Nighthawks     2nd     616        2  1400        26          3   \nMaine         Dragoons     1st      43        4  1592        73          2   \nIowa          Dragoons     1st     234        7  1006        37          1   \nAlaska        Dragoons     2nd     523        8   987       949          2   \nWashington    Dragoons     2nd      62        3   849        48          3   \nOregon          Scouts     1st      62        4   973        48          2   \nWyoming         Scouts     1st      73        7  1005       435          1   \nLouisana        Scouts     2nd      37        8  1099        63          2   \nGeorgia         Scouts     2nd      35        9  1523       345          3   \n\n            armored  deserters      origin  \norigin                                      \nArizona           1          4     Arizona  \nCalifornia        0         24  California  \nTexas             1         31       Texas  \nFlorida           1          2     Florida  \nMaine             0          3       Maine  \nIowa              1          4        Iowa  \nAlaska            0         24      Alaska  \nWashington        1         31  Washington  \nOregon            0          2      Oregon  \nWyoming           0          3     Wyoming  \nLouisana          1          2    Louisana  \nGeorgia           1          3     Georgia  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>California</td>\n    </tr>\n    <tr>\n      <th>Texas</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Texas</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Florida</td>\n    </tr>\n    <tr>\n      <th>Maine</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>43</td>\n      <td>4</td>\n      <td>1592</td>\n      <td>73</td>\n      <td>2</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Maine</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Iowa</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>Alaska</td>\n    </tr>\n    <tr>\n      <th>Washington</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>62</td>\n      <td>3</td>\n      <td>849</td>\n      <td>48</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Washington</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>Oregon</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Wyoming</td>\n    </tr>\n    <tr>\n      <th>Louisana</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>37</td>\n      <td>8</td>\n      <td>1099</td>\n      <td>63</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Louisana</td>\n    </tr>\n    <tr>\n      <th>Georgia</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>35</td>\n      <td>9</td>\n      <td>1523</td>\n      <td>345</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>Georgia</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.index = army['origin']\n",
    "army"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 5. Print only the column veterans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:50:07.476802Z",
     "start_time": "2024-01-11T12:50:07.454123Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "origin\nArizona         1\nCalifornia      5\nTexas          62\nFlorida        26\nMaine          73\nIowa           37\nAlaska        949\nWashington     48\nOregon         48\nWyoming       435\nLouisana       63\nGeorgia       345\nName: veterans, dtype: int64"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army['veterans']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 6. Print the columns 'veterans' and 'deaths'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:50:28.077393Z",
     "start_time": "2024-01-11T12:50:28.053136Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "            veterans  deaths\norigin                      \nArizona            1     523\nCalifornia         5      52\nTexas             62      25\nFlorida           26     616\nMaine             73      43\nIowa              37     234\nAlaska           949     523\nWashington        48      62\nOregon            48      62\nWyoming          435      73\nLouisana          63      37\nGeorgia          345      35",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>veterans</th>\n      <th>deaths</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>1</td>\n      <td>523</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>5</td>\n      <td>52</td>\n    </tr>\n    <tr>\n      <th>Texas</th>\n      <td>62</td>\n      <td>25</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>26</td>\n      <td>616</td>\n    </tr>\n    <tr>\n      <th>Maine</th>\n      <td>73</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>37</td>\n      <td>234</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>949</td>\n      <td>523</td>\n    </tr>\n    <tr>\n      <th>Washington</th>\n      <td>48</td>\n      <td>62</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>48</td>\n      <td>62</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>435</td>\n      <td>73</td>\n    </tr>\n    <tr>\n      <th>Louisana</th>\n      <td>63</td>\n      <td>37</td>\n    </tr>\n    <tr>\n      <th>Georgia</th>\n      <td>345</td>\n      <td>35</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army[['veterans','deaths']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 7. Print the name of all the columns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:50:40.468944Z",
     "start_time": "2024-01-11T12:50:40.457547Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "array(['regiment', 'company', 'deaths', 'battles', 'size', 'veterans',\n       'readiness', 'armored', 'deserters', 'origin'], dtype=object)"
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.columns.values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 8. Select the 'deaths', 'size' and 'deserters' columns from Maine and Alaska"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:52:53.475977Z",
     "start_time": "2024-01-11T12:52:53.462791Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "        deaths  size  deserters\norigin                         \nMaine       43  1592          3\nAlaska     523   987         24",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>deaths</th>\n      <th>size</th>\n      <th>deserters</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Maine</th>\n      <td>43</td>\n      <td>1592</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>523</td>\n      <td>987</td>\n      <td>24</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.loc[army.index.isin([\"Maine\",\"Alaska\"]),[\"deaths\",\"size\",\"deserters\"]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 9. Select the rows 3 to 7 and the columns 3 to 6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:54:31.756841Z",
     "start_time": "2024-01-11T12:54:31.736430Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "         deaths  battles  size  veterans\norigin                                  \nTexas        25        2  1099        62\nFlorida     616        2  1400        26\nMaine        43        4  1592        73\nIowa        234        7  1006        37\nAlaska      523        8   987       949",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Texas</th>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n    </tr>\n    <tr>\n      <th>Maine</th>\n      <td>43</td>\n      <td>4</td>\n      <td>1592</td>\n      <td>73</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.iloc[2:7,2:6]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 10. Select every row after the fourth row and all columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:56:05.180506Z",
     "start_time": "2024-01-11T12:56:05.163921Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "            regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                     \nMaine       Dragoons     1st      43        4  1592        73          2   \nIowa        Dragoons     1st     234        7  1006        37          1   \nAlaska      Dragoons     2nd     523        8   987       949          2   \nWashington  Dragoons     2nd      62        3   849        48          3   \nOregon        Scouts     1st      62        4   973        48          2   \nWyoming       Scouts     1st      73        7  1005       435          1   \nLouisana      Scouts     2nd      37        8  1099        63          2   \nGeorgia       Scouts     2nd      35        9  1523       345          3   \n\n            armored  deserters      origin  \norigin                                      \nMaine             0          3       Maine  \nIowa              1          4        Iowa  \nAlaska            0         24      Alaska  \nWashington        1         31  Washington  \nOregon            0          2      Oregon  \nWyoming           0          3     Wyoming  \nLouisana          1          2    Louisana  \nGeorgia           1          3     Georgia  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Maine</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>43</td>\n      <td>4</td>\n      <td>1592</td>\n      <td>73</td>\n      <td>2</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Maine</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Iowa</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>Alaska</td>\n    </tr>\n    <tr>\n      <th>Washington</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>62</td>\n      <td>3</td>\n      <td>849</td>\n      <td>48</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Washington</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>Oregon</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Wyoming</td>\n    </tr>\n    <tr>\n      <th>Louisana</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>37</td>\n      <td>8</td>\n      <td>1099</td>\n      <td>63</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Louisana</td>\n    </tr>\n    <tr>\n      <th>Georgia</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>35</td>\n      <td>9</td>\n      <td>1523</td>\n      <td>345</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>Georgia</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.iloc[4:,:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 11. Select every row up to the 4th row and all columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:56:21.258151Z",
     "start_time": "2024-01-11T12:56:21.229338Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "              regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                       \nArizona     Nighthawks     1st     523        5  1045         1          1   \nCalifornia  Nighthawks     1st      52       42   957         5          2   \nTexas       Nighthawks     2nd      25        2  1099        62          3   \nFlorida     Nighthawks     2nd     616        2  1400        26          3   \n\n            armored  deserters      origin  \norigin                                      \nArizona           1          4     Arizona  \nCalifornia        0         24  California  \nTexas             1         31       Texas  \nFlorida           1          2     Florida  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>California</td>\n    </tr>\n    <tr>\n      <th>Texas</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Texas</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Florida</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.iloc[:4,:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 12. Select the 3rd column up to the 7th column"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:56:56.036938Z",
     "start_time": "2024-01-11T12:56:56.011261Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "            deaths  battles  size  veterans  readiness\norigin                                                \nArizona        523        5  1045         1          1\nCalifornia      52       42   957         5          2\nTexas           25        2  1099        62          3\nFlorida        616        2  1400        26          3\nMaine           43        4  1592        73          2\nIowa           234        7  1006        37          1\nAlaska         523        8   987       949          2\nWashington      62        3   849        48          3\nOregon          62        4   973        48          2\nWyoming         73        7  1005       435          1\nLouisana        37        8  1099        63          2\nGeorgia         35        9  1523       345          3",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>Texas</th>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>Maine</th>\n      <td>43</td>\n      <td>4</td>\n      <td>1592</td>\n      <td>73</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>Washington</th>\n      <td>62</td>\n      <td>3</td>\n      <td>849</td>\n      <td>48</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>Louisana</th>\n      <td>37</td>\n      <td>8</td>\n      <td>1099</td>\n      <td>63</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>Georgia</th>\n      <td>35</td>\n      <td>9</td>\n      <td>1523</td>\n      <td>345</td>\n      <td>3</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.iloc[:,2:7]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 13. Select rows where df.deaths is greater than 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:58:20.013001Z",
     "start_time": "2024-01-11T12:58:20.000966Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "              regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                       \nArizona     Nighthawks     1st     523        5  1045         1          1   \nCalifornia  Nighthawks     1st      52       42   957         5          2   \nFlorida     Nighthawks     2nd     616        2  1400        26          3   \nIowa          Dragoons     1st     234        7  1006        37          1   \nAlaska        Dragoons     2nd     523        8   987       949          2   \nWashington    Dragoons     2nd      62        3   849        48          3   \nOregon          Scouts     1st      62        4   973        48          2   \nWyoming         Scouts     1st      73        7  1005       435          1   \n\n            armored  deserters      origin  \norigin                                      \nArizona           1          4     Arizona  \nCalifornia        0         24  California  \nFlorida           1          2     Florida  \nIowa              1          4        Iowa  \nAlaska            0         24      Alaska  \nWashington        1         31  Washington  \nOregon            0          2      Oregon  \nWyoming           0          3     Wyoming  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>California</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Florida</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Iowa</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>Alaska</td>\n    </tr>\n    <tr>\n      <th>Washington</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>62</td>\n      <td>3</td>\n      <td>849</td>\n      <td>48</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Washington</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>Oregon</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Wyoming</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army[army[\"deaths\"] > 50]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 14. Select rows where df.deaths is greater than 500 or less than 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T12:59:44.980290Z",
     "start_time": "2024-01-11T12:59:44.945332Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "              regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                       \nArizona     Nighthawks     1st     523        5  1045         1          1   \nCalifornia  Nighthawks     1st      52       42   957         5          2   \nTexas       Nighthawks     2nd      25        2  1099        62          3   \nFlorida     Nighthawks     2nd     616        2  1400        26          3   \nMaine         Dragoons     1st      43        4  1592        73          2   \nIowa          Dragoons     1st     234        7  1006        37          1   \nAlaska        Dragoons     2nd     523        8   987       949          2   \nWashington    Dragoons     2nd      62        3   849        48          3   \nOregon          Scouts     1st      62        4   973        48          2   \nWyoming         Scouts     1st      73        7  1005       435          1   \nLouisana        Scouts     2nd      37        8  1099        63          2   \nGeorgia         Scouts     2nd      35        9  1523       345          3   \n\n            armored  deserters      origin  \norigin                                      \nArizona           1          4     Arizona  \nCalifornia        0         24  California  \nTexas             1         31       Texas  \nFlorida           1          2     Florida  \nMaine             0          3       Maine  \nIowa              1          4        Iowa  \nAlaska            0         24      Alaska  \nWashington        1         31  Washington  \nOregon            0          2      Oregon  \nWyoming           0          3     Wyoming  \nLouisana          1          2    Louisana  \nGeorgia           1          3     Georgia  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>California</td>\n    </tr>\n    <tr>\n      <th>Texas</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Texas</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Florida</td>\n    </tr>\n    <tr>\n      <th>Maine</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>43</td>\n      <td>4</td>\n      <td>1592</td>\n      <td>73</td>\n      <td>2</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Maine</td>\n    </tr>\n    <tr>\n      <th>Iowa</th>\n      <td>Dragoons</td>\n      <td>1st</td>\n      <td>234</td>\n      <td>7</td>\n      <td>1006</td>\n      <td>37</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Iowa</td>\n    </tr>\n    <tr>\n      <th>Alaska</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>523</td>\n      <td>8</td>\n      <td>987</td>\n      <td>949</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>Alaska</td>\n    </tr>\n    <tr>\n      <th>Washington</th>\n      <td>Dragoons</td>\n      <td>2nd</td>\n      <td>62</td>\n      <td>3</td>\n      <td>849</td>\n      <td>48</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Washington</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>Oregon</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Wyoming</td>\n    </tr>\n    <tr>\n      <th>Louisana</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>37</td>\n      <td>8</td>\n      <td>1099</td>\n      <td>63</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Louisana</td>\n    </tr>\n    <tr>\n      <th>Georgia</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>35</td>\n      <td>9</td>\n      <td>1523</td>\n      <td>345</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>Georgia</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army[(army.deaths > 500) | (army.deaths) < 50]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 15. Select all the regiments not named \"Dragoons\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T13:00:51.887878Z",
     "start_time": "2024-01-11T13:00:51.874509Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "              regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                       \nArizona     Nighthawks     1st     523        5  1045         1          1   \nCalifornia  Nighthawks     1st      52       42   957         5          2   \nTexas       Nighthawks     2nd      25        2  1099        62          3   \nFlorida     Nighthawks     2nd     616        2  1400        26          3   \nOregon          Scouts     1st      62        4   973        48          2   \nWyoming         Scouts     1st      73        7  1005       435          1   \nLouisana        Scouts     2nd      37        8  1099        63          2   \nGeorgia         Scouts     2nd      35        9  1523       345          3   \n\n            armored  deserters      origin  \norigin                                      \nArizona           1          4     Arizona  \nCalifornia        0         24  California  \nTexas             1         31       Texas  \nFlorida           1          2     Florida  \nOregon            0          2      Oregon  \nWyoming           0          3     Wyoming  \nLouisana          1          2    Louisana  \nGeorgia           1          3     Georgia  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Arizona</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n    <tr>\n      <th>California</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>52</td>\n      <td>42</td>\n      <td>957</td>\n      <td>5</td>\n      <td>2</td>\n      <td>0</td>\n      <td>24</td>\n      <td>California</td>\n    </tr>\n    <tr>\n      <th>Texas</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Texas</td>\n    </tr>\n    <tr>\n      <th>Florida</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>616</td>\n      <td>2</td>\n      <td>1400</td>\n      <td>26</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Florida</td>\n    </tr>\n    <tr>\n      <th>Oregon</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>62</td>\n      <td>4</td>\n      <td>973</td>\n      <td>48</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>Oregon</td>\n    </tr>\n    <tr>\n      <th>Wyoming</th>\n      <td>Scouts</td>\n      <td>1st</td>\n      <td>73</td>\n      <td>7</td>\n      <td>1005</td>\n      <td>435</td>\n      <td>1</td>\n      <td>0</td>\n      <td>3</td>\n      <td>Wyoming</td>\n    </tr>\n    <tr>\n      <th>Louisana</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>37</td>\n      <td>8</td>\n      <td>1099</td>\n      <td>63</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>Louisana</td>\n    </tr>\n    <tr>\n      <th>Georgia</th>\n      <td>Scouts</td>\n      <td>2nd</td>\n      <td>35</td>\n      <td>9</td>\n      <td>1523</td>\n      <td>345</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>Georgia</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army[army['regiment'] != 'Dragoons']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 16. Select the rows called Texas and Arizona"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T13:02:41.854149Z",
     "start_time": "2024-01-11T13:02:41.834978Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "           regiment company  deaths  battles  size  veterans  readiness  \\\norigin                                                                    \nTexas    Nighthawks     2nd      25        2  1099        62          3   \nArizona  Nighthawks     1st     523        5  1045         1          1   \n\n         armored  deserters   origin  \norigin                                \nTexas          1         31    Texas  \nArizona        1          4  Arizona  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>regiment</th>\n      <th>company</th>\n      <th>deaths</th>\n      <th>battles</th>\n      <th>size</th>\n      <th>veterans</th>\n      <th>readiness</th>\n      <th>armored</th>\n      <th>deserters</th>\n      <th>origin</th>\n    </tr>\n    <tr>\n      <th>origin</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Texas</th>\n      <td>Nighthawks</td>\n      <td>2nd</td>\n      <td>25</td>\n      <td>2</td>\n      <td>1099</td>\n      <td>62</td>\n      <td>3</td>\n      <td>1</td>\n      <td>31</td>\n      <td>Texas</td>\n    </tr>\n    <tr>\n      <th>Arizona</th>\n      <td>Nighthawks</td>\n      <td>1st</td>\n      <td>523</td>\n      <td>5</td>\n      <td>1045</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>4</td>\n      <td>Arizona</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.loc[[\"Texas\",\"Arizona\"],:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 17. Select the third cell in the row named Arizona"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-01-11T13:14:27.627679Z",
     "start_time": "2024-01-11T13:14:27.612399Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "origin\nArizona    523\nName: deaths, dtype: int64"
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "army.loc[[\"Arizona\"]].iloc[:,2]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 18. Select the third cell down in the column named deaths"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
